﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI
{
    /// <summary>
    /// 错误编码管理
    /// 0xFFFF00-0xFFFFFF为系统使用
    /// </summary>
    public static class ErrorCodes
    {
        /// <summary>
        /// 没有错误
        /// </summary>
        public const int NoError = 0xFFFF00;

        public static Hashtable s_errorCodes = new Hashtable();

        static ErrorCodes()
        {
            s_errorCodes.Add(NoError, "NoError");
        }

        public static void Register(int code, string message)
        {
            s_errorCodes.Add(code, message);
        }

        public static string Message(int code)
        {
            try
            {
                return (string)s_errorCodes[code];
            }
            catch(Exception ex)
            {
                return "Unknown error";
            }
        }
    }
}
